home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / 4dostool / 4laser.zip / 4LASER.DOC < prev    next >
Text File  |  1992-04-16  |  7KB  |  267 lines

  1.  
  2.  
  3.                 4LASER
  4.            4DOS Laser Configuration Utility
  5.  
  6.                   by
  7.  
  8.              Marshall E. Giguere
  9.  
  10.              CIS ID: [71511,3513]
  11.  
  12.                Created: April 16, 1992
  13.              Last Revised: April 16, 1992
  14.  
  15.  
  16. Introduction:
  17. -------------
  18.  
  19. The 4LASER utility defines a simple mnemonic command interface for
  20. sending configuration codes to an HP LaserJet Series II laser
  21. printer. I cobbled this utility together after getting tired of
  22. looking for my printer manual.  
  23.  
  24. Probably the most interesting feature of 4LASER is the generalized
  25. parsing facility and dispatching method that I developed to simplify
  26. handling command line parsing.  So if you don't have a LaserJet II
  27. you can simply rip out the action section of 4LASER and put your own
  28. on and you'll have a completly new program.
  29.  
  30. 4LASER is by no means presented as a complete product but rather as
  31. an interesting exploration of ideas.  You are encouraged to extent
  32. 4LASER with additional features and in fact this should be quite
  33. easy. 
  34.  
  35.  
  36. 4LASER commands:
  37. ----------------
  38.  
  39. The 4LASER utility accepts a sequence of commands on the 4DOS command
  40. line.  The 4LASER command line is:
  41.  
  42.     4LASER [command | command=argument]...
  43.  
  44. Example:
  45.  
  46.     4LASER portrait bold typeface=3 point=12 pitch=10
  47.  
  48. The above command sets the LJII to portrait mode with a bold face 12
  49. point courier font at 10 characters per inch.
  50.  
  51. Commands:
  52. ---------
  53.  
  54. Commands are of the form "name" or "name=arg" where arg maybe any
  55. string.  Command names are case-insensitive, i.e. "BOLD" and "bold"
  56. are the considered the same.
  57.  
  58. BOLD
  59.     Sets the weight factor to 3 for a bold typeface.
  60.  
  61. COURIER
  62.     Selects a 12 point, 10 pitch, portrait mode typeface
  63.     with 60 lines per page.
  64.  
  65. DEVICE=dev
  66.     Selects the port to which subsequent commands are sent.
  67.     The default port is LPT1.
  68.  
  69. ITALIC
  70.     Selects an italic type style for the current font.
  71.  
  72. LANDSCAPE
  73.     Places the page orientation to landscape.
  74.  
  75. LIGHT
  76.     Sets the weight to -3, or light print.
  77.  
  78. LINEPRINTER
  79.     Selects an 8.5 point, 16.66 pitch portrait mode font
  80.     with 80 line per page.
  81.  
  82. LITE
  83.     Same as LIGHT.
  84.  
  85. MEDIUM
  86.     Sets the print weight to 0 or medium print.
  87.  
  88. PITCH=#
  89.     Set the number of characters per inch (cpi) to the
  90.     value of #.
  91.  
  92. POINTSIZE=#
  93.     Selects the height of the font in points to the value of #.
  94.  
  95. PORTRIAT
  96.     Sets the page orientation to portriat.
  97.  
  98. RESET
  99.     Forces the printer into reset mode.
  100.  
  101. ROMAN
  102.     Selects a roman type style.
  103.  
  104. SYMBOLS=sym
  105.     Selects the symbol set used by the printer legal values are:
  106.  
  107.     sym value    Symbol set
  108.     ---------    --------------------
  109.      0N        ECMA-94 Latin 1
  110.      8U        Roman-8
  111.     10U        IBM-PC USA
  112.     11N        IBM Danish/Norwegian
  113.  
  114.     Consult your printer or cartridge manual for additional symbol sets.
  115.  
  116. TYPEFACE=#
  117.     Selects the typeface where # is one of the following.
  118.  
  119.     #   Typeface
  120.     -   ------------
  121.     0   line printer
  122.     1   Pica
  123.     2   Elite
  124.     3   Courier
  125.     4   Helvetica
  126.     5   Times Roman
  127.     6   Gothic
  128.     7   Script
  129.     8   Prestige
  130.     9   Caslon
  131.        10   Orator
  132.  
  133.        Consult your printer or cartridge manual for additional symbol sets.
  134.  
  135. VERTICALPITCH=#
  136.     Sets the vertical pitch, the number of lines per inch (lpi).  Legal
  137.     values are: 1,2,3,4,6,8,12,16,24,48.
  138.  
  139. WEIGHT=#
  140.     Sets the weight factor for the typeface.  Legal
  141.     values are: -7 to +7, where -7 is very light, 0 is normal
  142.     or medium, and +7 is very bold.
  143.  
  144.  
  145.  
  146. Restrictions:
  147. -------------
  148.  
  149. The current implementation of 4LASER sets only attributes of the
  150. primary font.  I did not consider this to be a serious limitation
  151. since you may encapsulate an unlimited number of configurations in
  152. any number of 4DOS aliases.
  153.  
  154.  
  155.  
  156. Theory and Other Advance Concepts:
  157. ----------------------------------
  158.  
  159. As was noted in the introduction possibly the most useful idea in
  160. 4LASER is not the ability to configure your LJII but rather the
  161. method of extracting information from a 4DOS command line and
  162. selecting the appropriate action.
  163.  
  164.  
  165. Rules and Actions:
  166. ------------------
  167.  
  168. 4LASER uses the simple but powerful idea from production systems of
  169. rule/action pairs.  Productions consist of two parts a rule clause
  170. and an action clause, e.g. rule {action}.  In the case of 4LASER the
  171. rule clauses are simply strings separated by whitespace and the
  172. action clauses are blocks of code declared with a label of the same
  173. string as the rule, e.g. COURIER is the rule and the :COURIER label
  174. introduces the action clause within the 4LASER.BTM file.  A rule in
  175. 4LASER is said to fire when it matches a label that is
  176. lexicographical equal to the rule name.  This is admittedly a gross
  177. simplification but it provides a lot of power for little effort.
  178.  
  179. The job of the parser is then simply to identify rules, and any
  180. subsequent arguments and to then invoke the action clause.  This
  181. process continues until the 4DOS command line is exhausted.  The
  182. process of selection, action and execution is performed by the main
  183. processing loop within the :LOOP scope.  The tokenization of the
  184. command arguments is handled by the routine :LEX with the actual
  185. execution being done by the :EXEC routine.  This division of labor
  186. makes a simple yet powerful parsing tool for 4DOS batch programs that
  187. require a mnemonic command syntax.
  188.  
  189.  
  190. Parser Architecture:
  191. --------------------
  192.  
  193. The architecture of 4LASER has been generalized to permit its use for
  194. any number of jobs.  The architecture is:
  195.  
  196.  
  197.     -------------------
  198.     |          |
  199.     |Parser/Dispatcher|
  200.     |          |
  201.     -------------------
  202.     |          |
  203.     |          |
  204.     |     Actions      |
  205.     |          |
  206.     |          |
  207.     -------------------
  208.  
  209. The Parser/Dispatcher section may be separated from the 4LASER.BTM
  210. file and placed on top of another, different, actions section.  The
  211. parser provides parsing for rules of the forms:
  212.  
  213.     rule := name | name=arg
  214.     name := <any string>
  215.     arg  := <any string>
  216.  
  217.  
  218. The :LEX Function:
  219. ------------------
  220.  
  221. The :LEX function manages the command line and returns rule names and
  222. their arguments on request.  Internally rule names and arg's are
  223. returned by the :LEX function in the variables %FUNC and %ARG.  At
  224. this time :LEX assumes arguments are introduced by the "=" symbol.
  225.  
  226. It is of value to note that :LEX is self contained and action clauses
  227. may safely it if they require more input than initially supplied
  228. by :LEX.
  229.  
  230.  
  231. Action Clause Structure:
  232. ------------------------
  233.  
  234. Action clauses are handled as 4DOS subroutines.  That means that
  235. actions are invoked by a "GOSUB label" operation where the "label" is
  236. the same as rule name.  This means that architecturally actions are
  237. in fact subroutines and therefore must return.  The general structure
  238. of an action clause is:
  239.  
  240.     :rule-name
  241.         {action code goes here}
  242.     RETURN
  243.     
  244. Example:
  245.  
  246. The courier command is implemented with this action clause.
  247.  
  248.     :c
  249.     :co
  250.     :cour
  251.     :courier
  252.         set code=eEe&l6De(10Ue(s0p10h12v0s0b3Tr
  253.     return
  254.  
  255. Note the use of several successive labels to declare the courier
  256. action clause.  This allows a short hand rule name to be used in
  257. place of the full rule name.
  258.  
  259.  
  260. Conclusion:
  261. -----------
  262.  
  263. The 4LASER utility demonstrates how a simple but elegant command line
  264. parser can be created using only the capabilities of a simple string
  265. interpreter like 4DOS.
  266.  
  267.